package com.coolwen.service;

import com.coolwen.dao.OrderMapper;
import com.coolwen.entity.Order;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by user on 2016-11-10.
 */
@Service("orderService")
public class OrderServiceImpl implements OrderService {
    @Autowired
    OrderMapper orderMapper;
    //引入log4j,进行日志打印
    private static final Logger LOGGER = Logger.getLogger(OrderServiceImpl.class);


    @Override
    public Order findByOrderId(Integer orderId) {
        return orderMapper.selectByPrimaryKey(orderId);
    }

    @Override
    public List<Order> findByRequest(String requestType, String requestValue) {
        return null;
    }

    @Override
    public int deleteOrderByOrderId(Integer orderId) {
        return orderMapper.deleteByPrimaryKey(orderId);
    }

    @Override
    public int addOrder(Order order) {
        return orderMapper.insertSelective(order);
    }

    @Override
    public int updateOrderByOrderId(Order order) {
        return orderMapper.updateByPrimaryKeySelective(order);
    }

    @Override
    public List<Order> findOrderByUserId(Integer userId) {
        return orderMapper.selectByUserId(userId);
    }
}
